// pages/violation/violationList/violationList.js
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.request('/QueryOffenceLog/QueryOffence', 'GET',
      {
        userId: app.globalData.userId,
        hphm: options.plate,
        hpzl: options.typeId,
        engineno: options.engine,
        classno: options.frame
      }, res => {
        this.setData({ listData: res.lists});
      }, err => {
        wx.showModal({
          title: '查询失败',
          content: '请检查车辆信息是否填写正确',
          showCancel: false
        });
      }
    );
  },
  /**
   * 跳转详情页
   */
  goDetail(e) {
    let detailData = this.data.listData[e.currentTarget.dataset.index];
    wx.navigateTo({
      url: `/pages/violation/violationDetail/violationDetail?detailData=${JSON.stringify(detailData)}`,
    })
  }
})